package org.jsbd.boss.action;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.domian.HefenVO;
import org.jsbd.boss.service.IHefenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/hefen")
public class HefenController {

  private static final Logger logger = LoggerFactory.getLogger(HefenController.class);

  @Autowired
  private IHefenService hefenService;

  /**
   * 和粉统计页面
   * @return
   */
  @RequestMapping(value = "/list")
  public String daylimit() {
    return "hefen/list";
  }

  /**
   * 
   * 和粉统计数据
   * @param model
   * @return
   */
  @RequestMapping(value = "/listJson", method = RequestMethod.POST)
  @ResponseBody
  public Map<String, Object> listJson(DataGridModel page, HefenVO hefenVO) {
	  String startTime = hefenVO.getStartTime();
	  String endTime = hefenVO.getEndTime();
	  if (!StringUtils.isBlank(startTime) && startTime.contains("-")) {
		  hefenVO.setStartTime(startTime.replaceAll("-", ""));
	  }
	  if (!StringUtils.isBlank(endTime) && endTime.contains("-")) {
		  hefenVO.setEndTime(endTime.replaceAll("-", ""));
	  }
	  
	  return hefenService.findDataWithPage(page, hefenVO);
  }
  
}
